﻿Imports MySql.Data.MySqlClient
Public Class FAdd_Tropa

    Public con As New MySqlConnection
    Public DS As New DataSet

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click


       


        Me.Close()
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        OpenFileDialog1.ShowDialog()
        PictureBox1.ImageLocation = OpenFileDialog1.FileName
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        If ComboBox1.Text <> "" And ComboBox2.Text <> "" And TextBox1.Text <> "" Then
            Me.Close()
        Else
            MessageBox.Show("Info", "Faltan datos por completar", MessageBoxButtons.OK, MessageBoxIcon.Warning)
        End If
    End Sub

    Private Sub FAdd_Tropa_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Try
            con.ConnectionString = "server=localhost; user id=root; password=toor; database=army_builder_database"
            con.Open()

            'CARGAMOS EL COMBOBOX DE LOS EJERCITOS
            Dim Table As DataTable
            Dim query As String = "SELECT * FROM ejercitos order by nombre"
            Dim Comando As New MySql.Data.MySqlClient.MySqlCommand(query, con)
            Dim Adap As New MySql.Data.MySqlClient.MySqlDataAdapter(Comando)
            DS.Clear()
            Adap.Fill(DS, "ejercitos")
            Dim CommBuild As New MySql.Data.MySqlClient.MySqlCommandBuilder(Adap)

            Table = DS.Tables("ejercitos")

            For i As Integer = 0 To Table.Rows.Count - 1
                ComboBox1.Items.Add(Table.Rows(i).Item(1))
            Next



        Catch

        End Try


    End Sub
End Class